using admin.core.Entities.App;

namespace admin.core.Services;

public class RbacService
{
    // 判断用户是否对某资源有某操作权限
    public bool UserHasResourcePermission(AppUser user, string resourcePath, string permissionCode)
    {
        return user.Roles.Any(role =>
            role.Permissions.Any(permission =>
                permission.Code == permissionCode &&
                permission.Resources.Any(resource => resource.Path == resourcePath)
            )
        );
    }
}